//
//  UIBarButtonItem+Extensions.swift
//  WeiBo
//
//  Created by Li MAc on 2018/11/14.
//  Copyright © 2018 Li MAc. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    /// 创建UIBarButtonItem
    convenience  init(title:String,fotSize:CGFloat ,target:Any?,action: Selector , isBack:Bool) {
        
        let leftBut:UIButton = UIButton.cz_textButton(title, fontSize: fotSize , normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        
        leftBut.addTarget(target, action: action, for: .touchUpInside)
        
        //设置是否需要添加返回箭头图片
        if isBack{
            leftBut.setImage(UIImage(named: "navigationbar_back_withtext"), for: .normal)
            leftBut.setImage(UIImage(named: "navigationbar_back_withtext_highlighted"), for: .highlighted)
         leftBut.sizeToFit()
        }
        
        self.init(customView:leftBut)
    }
}
